package com.lamda.worker.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by MJiao on 15/8/14.
 */
public class SMSUtil {

    public static final String ACCOUNT = "cf_jxscwl";

    public static final String PASSWORD = "Aho123456A";

    public static boolean sendSMS(long phoneNum, int volidateCode) {
        String content = new String("您的验证码是：【变量】。请不要把验证码泄露给其他人。").replace("【变量】", String.valueOf(volidateCode));
        return SMSUtil.sendSMS(phoneNum, content);
    }

    public static boolean sendSMS(long phoneNum, String content) {
        String url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit&account=" + ACCOUNT + "&password=" + PASSWORD + "&mobile=" + phoneNum + "&content=您的验证码是：" + content + "。请不要把验证码泄露给其他人。";


        try {
            String result = HttpUtils.get(url, null);
            if (StringUtils.isNotEmpty(result) && result.contains("提交成功")){
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;

    }


}
